<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <title><%= title %></title>

    <!-- Bootstrap core CSS -->
    <link href="../css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="../css/starter-template.css" rel="stylesheet">

    <link href="../css/theme.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="../js/html5shiv.js"></script>
    <script src="../js/respond.min.js"></script>
    <![endif]-->

    <script type="text/javascript" src="../js/jquery-1.7.1.min.js"></script>
    <script src="../js/bootstrap.min.js"></script>

    <!--CodeMirror-->
    <link href="../css/codemirror.css" rel="stylesheet">
    <script src="../js/codemirror.min.js"></script>
    <script src="../js/sql.js"></script>

    <script type="text/javascript">

        $(function () {
//            $.get("/configs/categories/",[], function (data) {
//                $("#dblCategory").empty();
//                $("#dblCategory").append('<option value="">全部</option>')
//                data.rows.forEach(function(category) {
//                    $("#dblCategory").append('<option value=' + category.Value + '>' + category.Value + '</option>')
//                });
//            }, "JSON");

            $("#dblCategory").on("change",function() {
                $.get("/configs/search/", {category:$("#dblCategory").val()}, function (data) {
                    var html = "";
                    var i = 0
                    data.rows.forEach(function (row) {
                        i++;
                        html += "<tr><td>" + i +
                        "</td><td>" + row.Category +
                        "</td><td>" + row.Key +
                        "</td><td>" + row.Comment +
                        "</td><td>" + row.Value +
                        "</td><td>" + row.CreatedTS +
                        "</td><td>" + row.ChangedTS +
                        "</td><td></td></tr>";
                    });
                    $("#result tbody").html(html);
                }, "JSON");
            });

            $("form").on("submit", false);

        });
    </script>
</head>
<body>

<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/">互动平台报表发布系统</a>
        </div>
        <div class="collapse navbar-collapse">
            <ul class="nav navbar-nav">
                <li runat="server" id="liReportList"><a href="/reports/">报表列表</a></li>
                <li runat="server" id="liConfigList" class="active"><a href="/configs/">配置列表</a></li>
                <li runat="server" id="liReportCreate"><a href="/report/edit/0">新建</a></li>
            </ul>
        </div>
        <!--/.nav-collapse -->
    </div>
</div>

<div class="container">

    <div class="starter-template">
        <form id="form1">
            <!--<div>-->
                <!--<select id="dblNewestOnly" onchange="dblNewestOnly_SelectedIndexChanged">-->
                    <!--<option value="False">全部</option>-->
                    <!--<option value="True" selected="selected">最新</option>-->
                <!--</select>-->
                <!--<select id="dblPageNumber" onchange="dblPageNumber_SelectedIndexChanged"></select>-->
                <!--<select id="dblItemsPerPage" onchange="dblItemsPerPage_SelectedIndexChanged">-->
                    <!--<option value="20">20/页</option>-->
                    <!--<option value="50">50/页</option>-->
                    <!--<option value="100">100/页</option>-->
                    <!--<option value="200">200/页</option>-->
                    <!--<option value="500">500/页</option>-->
                <!--</select>-->
                <!--<select id="dblPlatform" onchange="dblPlatform_SelectedIndexChanged"></select>-->
                <!--<select id="dblProvince" onchange="dblProvince_SelectedIndexChanged"></select>-->
                <!--<input type="text" id="txtName" onchange="txtName_TextChanged">-->
            <!--</div>-->
            <div>
                <select id="dblCategory">
                    <option value="" selected="selected">全部</option>
                    <option value="System">系统配置</option>
                    <option value="User">用户配置</option>
                </select>
            </div>
            <div style="margin-top: 10px;">

                <table id="result" class="table table-bordered">
                    <thead>
                        <tr>
                            <th>行号</th>
                            <th>分类</th>
                            <th>键</th>
                            <th>描述</th>
                            <th>值</th>
                            <th>创建时间</th>
                            <th>修改时间</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody><% if (rows != null) { var i = 0; rows.forEach(function(row){ i++; %>
                        <tr>
                            <td><%=i%></td>
                            <td><%=row.Category%></td>
                            <td><a href="/configs/edit/<%=row.Id%>"><%=row.Key%></a></td>
                            <td><%=row.Comment%></td>
                            <td><%=row.Value%></td>
                            <td><%=row.CreatedTS%></td>
                            <td><%=row.ChangedTS%></td>
                            <td><a href="/configs/edit/<%=row.Id%>">编辑</a></td>
                        </tr>
                    <% }) }; %>
                    </tbody>
                </table>
                <input type="button" class="btn btn-primary" style="width:100%; margin-top:10px;" value="添加" onclick="window.location = '/configs/edit/0'" />
            </div>
        </form>
    </div>

</div>
<!-- /.container -->
</body>
</html>
